function [err] = set_ccpar()

sf=getmainselection;

QueMessage('Setting CC Parameters', 1);
for i = 1:length(sf)
    err = set_ccpar2(sf(i)); % do every selected entry in the list....
end;
return;


function [err] = set_ccpar2(sflag)
global CONTROL
global DFILE
err = 0;

QueMessage(sprintf('CC parameters for %s: %d', CONTROL(sflag).filename, CONTROL(sflag).recbeg));
if(DFILE.mode ~= 9)
    CONTROL(sflag).vgain=2;
else
    CONTROL(sflag).vgain = 0.1;
end;
CONTROL(sflag).igain=1;
CONTROL(sflag).jpot=-12; % kgluc
CONTROL(sflag).mode='CC';
% set timing according to the protocol we have
prot = unblank(CONTROL(sflag).protocol);
switch(prot)
    case {'iv', 'cciv'}
        CONTROL(sflag).durho=10;
        CONTROL(sflag).durs1=100;
        CONTROL(sflag).durs2=0;
        CONTROL(sflag).durs3=0;
        QueMessage(sprintf('Durations for %s', prot));

    case {'ap-iv'}
        CONTROL(sflag).durho=5;
        CONTROL(sflag).durs1=100;
        CONTROL(sflag).durs2=0;
        CONTROL(sflag).durs3=0;
        QueMessage(sprintf('Durations for %s', prot));
    case {'ap-iv2'}
        CONTROL(sflag).durho=10;
        CONTROL(sflag).durs1=500;
        CONTROL(sflag).durs2=0;
        CONTROL(sflag).durs3=0;
        QueMessage(sprintf('Durations for %s', prot));
    case {'ap-ivl', 'ap-ivl2'}
        CONTROL(sflag).durho=5;
        CONTROL(sflag).durs1=500;
        CONTROL(sflag).durs2=0;
        CONTROL(sflag).durs3=0;
        QueMessage(sprintf('Durations for %s', prot));

    case {'ap-hyp', 'ap-hyp2', 'ap-hyp3', 'mc-hyp2'}
        CONTROL(sflag).durho=5;
        CONTROL(sflag).durs1=100;
        CONTROL(sflag).durs2=300;
        CONTROL(sflag).durs3=0;
        QueMessage(sprintf('Durations for %s', prot));

    case {'test_ap'}
        CONTROL(sflag).durho = 20;
        CONTROL(sflag).durs1 = 5;
        CONTROL(sflag).durs2 = 0;
        CONTROL(sflag).durs3=0;
        QueMessage(sprintf('Durations for %s', prot));

    case {'drugmonitor', 'drugtestiv'}
        CONTROL(sflag).durho=210;
        CONTROL(sflag).durs1=500;
        CONTROL(sflag).durs2=0;
        CONTROL(sflag).durs3=0;
        QueMessage(sprintf('Durations for %s', prot));


    case {'ltp_base'}
        CONTROL(sflag).durho=5;
        CONTROL(sflag).durs1=50;
        CONTROL(sflag).durs2=300;
        CONTROL(sflag).durs3=0;
        QueMessage(sprintf('Durations for %s', prot));

    case {'hyp', 'hyps'}
        CONTROL(sflag).durho=10;
        CONTROL(sflag).durs1=50;
        CONTROL(sflag).durs2=100;
        CONTROL(sflag).durs3=0;
        QueMessage(sprintf('Durations for %s', prot));

    case {'hypdrug', 'hypsave', 'hypwatch'}
        CONTROL(sflag).durho = 5;
        CONTROL(sflag).durs1 = 100;
        CONTROL(sflag).durs2 = 300;
        CONTROL(sflag).durs3 = 0;
        QueMessage(sprintf('Durations for %s', prot));

    case {'hypl'}    % scott's
        CONTROL(sflag).durho=20;
        CONTROL(sflag).durs1=100;
        CONTROL(sflag).durs2=200;
        CONTROL(sflag).durs3=0;
        QueMessage(sprintf('Durations for %s', prot));

    case 'buildup'
        CONTROL(sflag).durho=10;
        CONTROL(sflag).durs1=100;
        CONTROL(sflag).durs2=100;
        CONTROL(sflag).durs3=0;
        QueMessage(sprintf('Durations for %s', prot));

    case {'forward', 'forward_watch'}
        CONTROL(sflag).durho=10;
        CONTROL(sflag).durs1=100;
        CONTROL(sflag).durs2=100;
        CONTROL(sflag).durs3=100;
        QueMessage(sprintf('Durations for %s', prot));

    case {'forward2'}
        CONTROL(sflag).durho=5;
        CONTROL(sflag).durs1=100;
        CONTROL(sflag).durs2=1205;
        CONTROL(sflag).durs3=100;
        QueMessage(sprintf('Durations for %s', prot));


    case {'timing_base', 'timing_cond'}
        CONTROL(sflag).durho=150;
        CONTROL(sflag).durs1=25;
        CONTROL(sflag).durs2=10;
        CONTROL(sflag).durs3=0;
        CONTROL(sflag).psp_time = '[4.5,7.1,40,60]';
        CONTROL(sflag).stim_time = '[5]';
        QueMessage(sprintf('Durations and stims for %s', prot));

    otherwise
        QueMessage(sprintf('set_ccpar: Protocol <%s> is not known for CC', prot));
        % DO NOTHING if protocol is NOT in the list.....
end;

return;

